<?php
/**
 * Description
 *
 * PHP version 7
 *
 * @category Custom
 * @package  Custom
 * @author   ryu <mo5467@126.com>
 * @date     2020-04-29 00:00:21
 * @lastTime 2020-04-29 00:21:51
 * @license  https://opensource.org/licenses/MIT MIT License
 * @link     none
 */
namespace Design\Behavioral\Specification;

class AndSpecification implements Specification
{

    private $specifications = [];


    public function __construct(Specification ...$specifications)
    {
        $this->specifications = $specifications;

    }//end __construct()


    public function isSatisfiedBy(Item $item) : bool
    {
        foreach ($this->specifications as $specification) {
            if (!$specification->isSatisfiedBy($item)) {
                return false;
            }
        }

        return true;

    }//end isSatisfiedBy()


}//end class
